<?php include_stylesheets_for_form($form) ?>
<?php include_javascripts_for_form($form) ?>
<script type="text/javascript">
var new_phone_index=2;
var new_address_index=2;
</script>


			<div id="indicator" class='indicator' style="display:none">....Processing...</div>

<form action="<?php echo url_for('mc/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?id='.$form->getObject()->getid() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
<?php if (!$form->getObject()->isNew()): ?>
<input type="hidden" name="sf_method" value="put" />
<?php endif; ?>
  <table>
    <tfoot>
      <tr>
        <td colspan="2">
          &nbsp;<a href="<?php echo url_for('main/index') ?>">Cancel</a>
          <?php if (!$form->getObject()->isNew()): ?>
            &nbsp;<?php echo link_to('Delete', 'mc/delete?id='.$form->getObject()->getid(), array('method' => 'delete', 'confirm' => 'Are you sure?')) ?>
          <?php endif; ?>
          <input type="submit" value="Save" />
        </td>
      </tr>
    </tfoot>
    <tbody>
      <?//php echo $form ?>
    </tbody>
  </table>


<table>
	
	<tfoot>
    <tr>
      <td colspan="2">
        &nbsp;<a href="<?php echo url_for('main/index') ?>">Cancel</a>
        <?php if (!$form->getObject()->isNew()): ?>
          &nbsp;<?php echo link_to('Delete', 'mc/delete?id='.$form->getObject()->getid(), array('method' => 'delete', 'confirm' => 'Are you sure?')) ?>
        <?php endif; ?>
        <input type="submit" value="Save" />
      </td>
    </tr>
  </tfoot>
	
	
	
	<tr>
    <td colspan="3">
	   	<?php echo $form['_csrf_token']; ?>
			<?php echo $form['id']; ?>
      <?php echo $form->renderGlobalErrors() ?>
      <?php echo $form['author']->render(); ?>
    </td>
  </tr>
  
	
	
	<tr>
		<td colspan=3>
		<table><!--Main client Info Block -->
	      <th><?php echo $form['name']->renderLabel() ?>:</th>
	      <td>
	        <?php echo $form['name']->renderError() ?>
	        <?php echo $form['name'] ?>
	      </td>
				<th><?php echo $form['mc_no']->renderLabel() ?>:</th>
	      <td>
	        <?php echo $form['mc_no']->renderError() ?>
	        <?php echo $form['mc_no'] ?>
	      </td>
	      <th><?php echo $form['client_type']->renderLabel() ?>:</th>
	      <td>
	        <?php echo $form['client_type']->renderError() ?>
	        <?php echo $form['client_type'] ?>
	      </td>
		</table>
		</td>
	</tr>	
	<tr>
		<td valign=top><!--Address Block column1 -->
			<fieldset>
				<legend>Address</legend>
				
			  <?php foreach($form['addresss'] as $formAddress): ?>
		      <?php include_partial('address', array('form'=>$formAddress)); ?>
		    <?php endforeach; ?>
				<div id="address-fieldset"></div>				
				<div class="right">
					<a href="#" onclick="jQuery.post(
						'<?php echo url_for('mc/addAddressAjax') ?>', 
						{ address_index: new_address_index },
					 function(data, textStatus) {
						jQuery('#address-fieldset').append(data); },
						'html'
						);
					new_address_index = new_address_index+1;" 
				 title="add another address">Add another Address</a>
			</fieldset>
		</td>
		<td valign=top><!--Phone Block column2 -->
			<fieldset>
				<legend>Phone</legend>
				<!--Show the previous entered Phones. Must find a way to enclose it into a hidden div. -->
		  <?php foreach($form['phones'] as $formPhone): ?>
	      <?php include_partial('phone', array('form'=>$formPhone)); ?>
	    <?php endforeach; ?>
			<div id="phones-fieldset"></div>				
			<div class="right">
				<a href="#" onclick="jQuery.post(
					'<?php echo url_for('mc/addPhoneAjax') ?>', 
					{ phone_index: new_phone_index },
				 function(data, textStatus) {
					jQuery('#phones-fieldset').append(data); },
					'html'
					);
				new_phone_index = new_phone_index+1;" 
			 title="add another phone">Add another Phone</a>


			</div>
			</fieldset>
		</td>
		<td valign=top><!--Misc Info Block column3-->
			<table>
				<tr>
					<td>
						<fieldset>
							<legend>Email</legend>
			
						  <?php foreach($form['emails'] as $formEmail): ?>
					      <?php include_partial('email', array('form'=>$formEmail)); ?>
					    <?php endforeach; ?>
			
						</fieldset>
				</td>
				</tr>
				<tr>
					<td>
						<fieldset>
								<legend>Websites</legend>
								
							  <?php foreach($form['websites'] as $formWebsite): ?>
						      <?php include_partial('websites', array('form'=>$formWebsite)); ?>
						    <?php endforeach; ?>

						</fieldset>
					</td>
				</tr>
				
				<tr>
					<td>
					<table>
						<td>
						<fieldset>
							<legend>Social Media Accounts</legend>


					  <?php foreach($form['socialmediaaccounts'] as $formSMA): ?>
				      <?php include_partial('socialmediaaccounts', array('form'=>$formSMA)); ?>
				    <?php endforeach; ?>
		
						</fieldset>
		
		
		      	</td>

					</table>	
				</tr>

			</table>
		</td>
	</tr>
	

	

</table>

</form>



